package com.chenfan.mcn.component.dict;

import com.chenfan.common.extension.context.SpringContextHolder;
import com.chenfan.common.extension.dict.DictTranslator;
import com.chenfan.mcn.model.StarAccountInfo;
import com.chenfan.mcn.service.StarAccountInfoService;

import java.util.Objects;

/**
 * 红人收款账户-翻译成名称
 *
 * @author wulg
 * @date 2022-01-21
 **/
public class StarAccountInfoIdTranslator implements DictTranslator<Long, String> {

    @Override
    public String translate(Long starAccountId) {
        StarAccountInfoService starAccountInfoService = SpringContextHolder.getBean(StarAccountInfoService.class);
        StarAccountInfo starAccountInfo = starAccountInfoService.getById(starAccountId);
        return Objects.nonNull(starAccountInfo) ? starAccountInfo.getAccountName() : starAccountId.toString();
    }
}
